package com.star.blog.controller;


import com.star.blog.common.Result;
import com.star.blog.service.TagService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 聂建强
 * @since 2021-11-20
 */
@RestController
@RequestMapping("/tags")
public class TagController {

    @Resource
    private TagService tagService;

    @GetMapping("/hot")
    public Result hot(){
        int limit=6;  //只查询最热的6条标签
        return tagService.hots(limit);
    }

    /**
     * 所有标签
     * @return
     */
    @GetMapping
    public Result findAll(){
        return tagService.findAll();
    }

    @GetMapping("detail")
    public Result findAllDetail(){
        return tagService.findAllDetail();
    }


    @GetMapping("detail/{id}")
    public Result findDetailById(@PathVariable("id") Long id){
        return tagService.findDetailById(id);
    }
}

